package com.saku.uiprojecttest.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

/**
 * User: Missa
 * Date: 2016-11-17
 * Time: 19:18
 * Description:
 */
public class AView extends View {
    public AView(Context context) {
        super(context);
    }

    public AView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public AView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public AView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        RectF rectF1 = new RectF(0, 0, getWidth(), getHeight());
        canvas.saveLayer(rectF1, new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG), Canvas.ALL_SAVE_FLAG);

        Paint paint = new Paint();
        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawCircle(100, 100, 50,paint);

        Paint paint2 = new Paint();
        paint2.setColor(Color.GREEN);
        paint2.setStyle(Paint.Style.FILL);
        paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
        RectF rectF = new RectF(100, 100, 200, 200);
        canvas.drawRect(rectF,paint2);

        canvas.restore();
    }
}
